package com.zhiyou100.www.bbs.function.topic;

import com.zhiyou100.www.bbs.dao.TableTitleDao;
import com.zhiyou100.www.bbs.dao.TableUserDao;
import com.zhiyou100.www.bbs.entityclass.TableTitle;
import com.zhiyou100.www.bbs.entityclass.TableUser;

import javax.jms.Session;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @packageName: ${NAME}
 * @className: ${PACKAGE_NAME}
 * @Description: TODO 根据标题搜索 话题
 * @author: yang
 * @date: 6/9/20
 */
@WebServlet(name = "SearchTheTopic", urlPatterns = "/SearchTheTopic")
public class SearchTheTopic extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        // 设定编码集
        response.setContentType("text/html;charset=UTF-8");
        // 设定类型

        String topic = request.getParameter("topic");
        // 获取话题

        TableTitleDao tableTitleDao = new TableTitleDao();
        // 创建 话题 dao

        ArrayList<TableTitle> all = tableTitleDao.topicSearch(topic);
        // 获取 所有查询的话题，指定实体类

        request.getSession().setAttribute("message", all);

        response.sendRedirect("/bbs/jsp/homepage.jsp");


    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    
}
